var async = require('async')

module.exports = function(app) {
  return new Handler(app)
}

var Handler = function(app) {
  this.app = app
  Handler.app = app
  this.sessionService = this.app.get('sessionService')
  this.channelService = this.app.get('channelService')
}

var handler = Handler.prototype
var local = {}

//获取我的战绩
handler.getMyHistory = function(msg,session,next) {
	var uid = session.get("uid")
	if(!uid){
		next(null,{flag : false})
		return
	}
	this.app.rpc.db.history.getHistory(null,uid,msg.count,function(flag,data){
		next(null,{flag : flag,data : data})
	})
}


//获取战绩详情
handler.getHistoryDetails = function(msg,session,next) {
	var uid = session.get("uid")
	if(!uid){
		next(null,{flag : false})
		return
	}
	var id = msg.id
	this.app.rpc.db.history.getHistoryDetails(null,id,function(data){
		if(data){
			next(null,{flag : true,data : data})
		}else{
			next(null,{flag : false})

		}
	})
}